﻿@model Commission.ViewModels.InputAmountModel
@using MyResources = Commission.Resources.AppResource

@{
    ViewBag.Title = "Create";
}

<h2>@MyResources.LinkInputAmount</h2>

@section MyJavascript {
    <script type="text/javascript">
    $(function () {
        $('#UserName').autocomplete(
        {
            source: '@Url.Action("UserNameSearch", "Customer")'
        }
        );

        $("#UserName").blur(function () {
            var UserName = $('#UserName').val();

            $.ajax({
                url: '/Customer/NameFromCode/',
                data: {
                    userName: UserName
                },
                success: function (data) {
                    $('#Name').val(data);
                },
                cache: false
            });
        });
    });
    </script>
}

@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form-group">
            <label class="control-label col-md-2" for="UserName">
                @MyResources.LabelUserName
            </label>

            <div class="col-md-10">
                @Html.TextBox("UserName", Model.UserName,
                    new { @class = "searchtext form-control", @style = "width:100px" })

                @Html.TextBox("Name", Model.Name,
                    new { @class = "searchtext form-control", @style = "width:177px", @readonly = "readonly" })
                
                @Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Amount">
                @MyResources.LabelAmount80
            </label>

            <div class="col-md-10">
                @Html.EditorFor(model => model.DisplayAmount80,
                    new { htmlAttributes = new { @class = "form-control text-right" } })
                @Html.ValidationMessageFor(model => model.DisplayAmount80, "", 
                    new { @class = "text-danger" })
            </div>
        </div>
        
        <div class="form-group">
            <label class="control-label col-md-2" for="Amount">
                @MyResources.LabelAmount20
            </label>
            
            <div class="col-md-10">
                @Html.EditorFor(model => model.DisplayAmount20,
                    new { htmlAttributes = new { @class = "form-control text-right" } })
                @Html.ValidationMessageFor(model => model.DisplayAmount20, "", 
                    new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2" for="Description">
                @MyResources.LabelDescription
            </label>

            <div class="col-md-10">
                @Html.EditorFor(model => model.Description, 
                    new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value=@MyResources.LinkInputAmount class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink(@MyResources.LinkBackToList, "Index")
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
